window.onload=function(){
    let personalLeft=document.getElementsByClassName("personal_left")[0];
    let Li=personalLeft.getElementsByTagName("li");
    let active=document.getElementsByClassName("active")[0];
    for(let i=0;i<Li.length;i++){
        Li[i].onclick=function(){
            for(let i=0;i<Li.length;i++){
                Li[i].className=" ";
            }
            this.className="active";
        }
    }
    /*改变左侧·导航栏的位置*/
    document.addEventListener('scroll',function(){
        let topJuLi = document.documentElement.scrollTop;
        personalLeft.style.top = (topJuLi)+"px";
    },true);

    // //修改资料输入框
    var inputColor=document.getElementsByClassName("inputColor");
    for(let i=0;i<inputColor.length;i++){
        inputColor[i].onfocus=function(){
            inputColor[i].style.border="1px solid #89c3eb";
        }
        inputColor[i].onblur=function(){
            inputColor[i].style.border="1px solid rgba(0,0,0,0.1)";
        }
    }
    //选择性别
    // let sexBtn=document.getElementsByClassName("sexBtn");
    // sexBtn[0].onclick=function(){
    //     sexBtn[0].style.border="1px solid #38a1db";
    //     sexBtn[1].style.border="1px solid #e5e5e5";
    // }
    // sexBtn[1].onclick=function(){
    //     sexBtn[1].style.border="1px solid #38a1db";
    //     sexBtn[0].style.border="1px solid #e5e5e5";
    // }

    //调色板
    let body=document.body;
    let paletteColor=document.getElementsByClassName("paletteColor")[0];
    let inputArr=paletteColor.querySelectorAll("input");
    let spanArr=paletteColor.querySelectorAll("span");
    let obj={
        R:0,
        G:0,
        B:0,
        A:0.2
    };
    for (let i=0;i<inputArr.length;i++){
        inputArr[i].addEventListener("input",function(){
            console.log("事件触发");
            if(i==3){
                spanArr[i].innerHTML=(inputArr[i].value)/100;
            }else{
                spanArr[i].innerHTML=inputArr[i].value;

            }
            console.log(this);
            switch (this.name) {
                case "R":
                    obj.R=this.value;
                    break;
                case "B":
                    obj.B=this.value;
                    break;
                case "G":
                    obj.G=this.value;
                    break;
                case "A":
                    obj.A=(this.value)/100;
                    break;
            }
            console.log(obj);
            body.style.backgroundColor = `rgba(${obj.R},${obj.G},${obj.B},${obj.A})`
        })
    }
    /*基本信息*/
    let info_exit=document.getElementsByClassName("info-exit");
    info_exit[0].innerHTML=sessionStorage.getItem('nickname');
    info_exit[1].innerHTML=sessionStorage.getItem('id');
    info_exit[2].innerHTML=sessionStorage.getItem('email');
    info_exit[3].innerHTML=sessionStorage.getItem('realname');
    info_exit[4].innerHTML=sessionStorage.getItem('sex');
    info_exit[5].innerHTML=sessionStorage.getItem('birthday');
    info_exit[6].innerHTML=sessionStorage.getItem('registTime');
}

let exit=document.getElementsByClassName("exit")[0];
let changeInformation=document.getElementsByClassName("changeInformation")[0];
let headInfo=document.getElementsByClassName("head-info")[0];
let infoCancleBtn=document.getElementById("infoCancleBtn");
let infoPreserveBtn=document.getElementById("infoPreserveBtn");
exit.onclick=function(){
    headInfo.style.display="none";
    changeInformation.style.display="block";
}
infoCancleBtn.onclick=function(){
    headInfo.style.display="block";
    changeInformation.style.display="none";
}
infoPreserveBtn.onclick=function(){
    headInfo.style.display="block";
    changeInformation.style.display="none";
}

let registerFindCodeInfoBox=document.getElementsByClassName("registerFindCodeInfoBox")[0];
let allInput=registerFindCodeInfoBox.getElementsByTagName("input");
for(let i=0;i<allInput.length;i++){
    allInput[5].onclick=function(){
        allInput[5].type='date';
    }
    allInput[5].onblur=function(){
        allInput[5].type='text';
    }
}

let userName=document.getElementById("user-name");
userName.innerHTML=sessionStorage.nickname;
